package com.longrise.android.byjk.plugins.tabsecond;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.longrise.android.byjk.model.AllCourseParentBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by callxkj on 2017/10/23.
 *  第二个tab 保险医学 的tab
 */

public class SecondFragmentPagerAdapter extends FragmentPagerAdapter {


    private List<AllCourseParentBean> mParentList = new ArrayList<>();

    public SecondFragmentPagerAdapter(FragmentManager fragmentManager){
        super(fragmentManager);
    }


    public void setData(List<AllCourseParentBean> parentList) {
        mParentList.clear();
        mParentList.addAll(parentList);
        this.notifyDataSetChanged();
    }


    @Override
    public Fragment getItem(int position) {
        SecondDetailFragment fragment = new SecondDetailFragment();
        Bundle bundle = new Bundle();
        bundle.putString(SecondDetailFragment.ASSORTMENTTYPEKEY,mParentList.get(position).getAssortmenttype());
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public int getCount() {
        return mParentList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        AllCourseParentBean allCourseParentBean = mParentList.get(position);
        String assortmentname = allCourseParentBean.getAssortmentname();
        return assortmentname;
    }
}
